package dbs

import (
	"gitee.com/RocsSun/report/models"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var dns string = "report:report1234@tcp(192.168.202.163:3306)/devops_report?charset=utf8mb4&parseTime=True&loc=Local"
var Client *gorm.DB

func init() {
	var err error

	Client, err = gorm.Open(mysql.Open(dns), &gorm.Config{})
	if err != nil {
		panic(err.Error())
	}
	Client.AutoMigrate(models.ReportModels...)
}

func Insert(data interface{}) *gorm.DB {
	return Client.Create(data)
}
